package ecom.appcode.business;

import java.util.List;

import ecom.appcode.common.daobean.UsersDaoBean;
import ecom.appcode.dao.daointerface.UsersDao;
import ecom.appcode.dao.daointerface.UsersDaoImpl;

public class UsersLogicImpl implements UsersLogic {

    /** check Login email and password */
    public boolean checkLogin(String email, String password) {
        UsersDao user = new UsersDaoImpl();
        boolean result = user.checkLogin(email, password);
        return result;
    };

    /** Register Account */
    public boolean registerAccount(String email, String password, String sex, String birthday, String firstName,
            String lastName, boolean admin, String address, int phoneNumber) {
        UsersDao user = new UsersDaoImpl();
        boolean result = user.registerAccount(email, password, sex, birthday, firstName, lastName, admin, address,
                phoneNumber);
        return result;
    }

    /** Select all Users for admin page */
    public List<UsersDaoBean> loadAllUsers() {
        UsersDao user = new UsersDaoImpl();
        List<UsersDaoBean> listUsers = user.loadAllUsers();
        return listUsers;
    }

    /** Select Users for admin page */
    public UsersDaoBean loadUsersByEmail(String strEmail) {
        UsersDao user = new UsersDaoImpl();
        UsersDaoBean userDao = user.loadUsersByEmail(strEmail);
        return userDao;
    }

    /** update User */
    public boolean updateAccount(String email, String password, String sex, String birthday, String firstName,
            String lastName, boolean admin, String address, int phoneNumber) {
        UsersDao user = new UsersDaoImpl();
        boolean result = user.updateAccount(email, password, sex, birthday, firstName, lastName, admin, address, phoneNumber);
        return result;
    }
    
    /** Delete User */
    public boolean deleteAccount(String email) {
        UsersDao user = new UsersDaoImpl();
        boolean result = user.deleteAccount(email);
        return result;
    }
}
